Welcome Guest | Sign in | Register

Home > C Programming > If statements > Questions and Answers

01. The statement that compares total for equality to good_guess, and if equal prints the value of total, and if not equal prints the value of good_guess, is
A. Statement 1
if( total < good_guess )
printf("%d", total );
else
printf("%d", good_guess );
B. Statement 2
if( total == good_guess )
printf("%d", good_guess );
else
printf("%d", total );
C. Statement 3
if( total = good_guess )
printf("%d", total );
else
printf("%d", good_guess );
D. Statement 4
if( total == good_guess )
printf("%d", total );
else
printf("%d", good_guess );

Answer and Explanation

Answer: Statement 4
if( total == good_guess )
printf("%d", total );
else
printf("%d", good_guess );

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
02. What will be the output
main()
{
int i;
i = 10;
if(i == 20 || 30)
{
printf("True");
}
else
{
printf("False");
}
}
A. True B. False
C. Syntax Error D. Run time Error

Answer and Explanation

Answer: True

Explanation:
i==20 is a expression which will return TRUE or FALSE depending on the value of i. In this program it will return 0 so the statement become
If ( 0 || 30)
30 is a nonzero value which means TRUE (1) in C when ORed with 0 will result TRUE.

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
03. What will be the output
main()
{
if(1,0)
{
printf("True");
}
else
{
printf("False");
}
}
A. True B. False
C. Compilation Error D. Run time Error

Answer and Explanation

Answer: False

Explanation:
comma(,) operator returns the value which at the right hand side of , . if statement become if(0)

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
04. What will be the output?
main()
{
int i, j, *ptr, *ptr1;
i = 10;
j = 10;
ptr = &i;
ptr1 = &j;
if(ptr == ptr1)
{
printf("True");
}
else
{
printf("False");
}
}
A. True B. False
C. Syntax Error D. Run time Error

Answer and Explanation

Answer: False

Explanation:
In this program we are comparing the addresses contained by ptr & ptr1 not the value at those addresses and pointers ptr and ptr1 have the addresses of different variables so above condition is false

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
05. Which one of the given option is correct?
void main()
{
int i;
i=2;
lucentblackboard:
printf("%d",i);
i=i+2;
if(i<=20)
goto lucentblackboard;

}
A. 3 5 7 9 ....... 21 23 B. 2 4 6 8 ....... 20
C. 3 5 7 9 ....... 21 D. 2 4 6 8 ....... 20 22

Answer and Explanation

Answer: 2 4 6 8 ....... 20

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
06. What is the output of the following code?
#include "stdio.h"
main(){
static int s;
++s;
printf("%d",s);
if(s<=3)
main();
printf("%d",s);
return 0;
}
A. 1 2 3 4 4 4 4 4 B. 0 1 2 3 4 4 4 4
C. 1 2 3 3 4 4 4 4 D. 0 1 3 4 4 4 4 4

Answer and Explanation

Answer: 1 2 3 4 4 4 4 4

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
07. What is the output of the following code?
void main()
{
int i;
i=0;
if(i=15,10,5)
printf("Programing %d",i);
else
printf("Skills %d",i);
getch ();
}
A. Skills 15 B. Programing 5
C. Programing 15 D. Skills 5

Answer and Explanation

Answer: Programing 15

Explanation:
Condition is true come inside if part and print Programing 15.

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
08. What is the output of the following program?
void main()
{
int i;
i=0;
if(i=55,0,10,0)
printf("Test Skills %d",i);
else
printf("C Programing %d",i);
getch ();
}
A. Test Skills 55 B. C Programing 0
C. Test Skills 0 D. C Programing 55

Answer and Explanation

Answer: C Programing 55

Explanation:
Condition is false come inside else part and print C Programing 55.

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
09. What is the output of following program?
void main(){
int a=80;
if(a++>80)
printf("welcome%d",a);
else
printf("hello%d",a);
}
A. hello 81 B. welcome 81
C. hello 80 D. welcome 80

Answer and Explanation

Answer: hello 81

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum
10. What is the output of following program?
void main(){
printf("One");
if(2>1)
printf("Two");
else
printf("Three");
printf("Four");
}
A. One Two Three B. Two Three Four
C. One Two Four D. One Three Four

Answer and Explanation

Answer: One Two Four

Explanation:
There is no explanation...

Report Errors

Name:

Loading...

VView Answer | RReport | DDiscuss in Forum



Partner Sites
LucentBlackBoard.com                  SoftLucent.com                  LucentJobs.com
All rights reserved © 2012-2015 SoftLucent.